package org.goodsl.mdd.gwt.box.server;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import org.goodsl.mdd.BoxBuilder;
import org.goodsl.mdd.BoxInfo;
import org.goodsl.mdd.gwt.box.client.BoxDescService;
import org.goodsl.mdd.gwt.box.shared.BoxDesc;

@SuppressWarnings("serial")
public class BoxDescServiceImpl  extends RemoteServiceServlet 
	implements BoxDescService {

	@Override
	public BoxDesc getBoxDesc(String boxClass) throws IllegalArgumentException,Exception {
        BoxInfo boxInfo = null;
        try {
            Class<?> cz =  Class.forName(boxClass);
            boxInfo = BoxBuilder.getBoxInfo(cz);
            if(boxInfo ==null){
            	return BoxDesc.emptyDesc;
                 
            }
        }catch (ClassNotFoundException e){

        	return BoxDesc.emptyDesc;
        }
      
	    return BoxDescUtil.getBoxDesc(boxInfo);
	}

}